/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-05-16
 * Time: 23:00
 */
public class rotate {
    public static void rotate(int[] nums, int k){
        int[] arr=new int[nums.length];
        k=k% nums.length;
        int n=k;
        for (int i= nums.length-1;i>nums.length-1-n;k--){
            arr[k-1]=nums[i];
            i--;
//            System.out.println(Arrays.toString(arr));
        }
        for (int i=0;i<nums.length-n;i++){
            arr[i+n]=nums[i];
//            System.out.println(Arrays.toString(arr));
        }
        for (int i=0;i<nums.length;i++){
            nums[i]=arr[i];
        }
    }
    public static void rotate1(int[] nums, int k) {
        k=k% nums.length;
        int len=nums.length-1;
        while(k>0){
            int last=nums[len];
            for (int i=len;i>0;i--){
                nums[i]=nums[i-1];
            }
            nums[0]=last;
            k--;
            //System.out.println(Arrays.toString(nums));
        }

    }

    public static void main(String[] args) {
        int[] num=new int[]{-1};
        rotate(num,2 );

    }
}
